<?php 
session_start();
if(isset($_SESSION['usuario'])) {
include 'cabecera.php';

include 'connect.php';

$query = "SELECT p.id, a.id AS aviso, a.titulo AS nombre_aviso, pe.id AS perfil, pe.nombre||' '||pe.apellido AS nombre_perfil, p.fecha, p.estado
FROM postulantes p
JOIN avisos a ON a.id = p.aviso
JOIN perfiles pe ON pe.id = p.perfiles
WHERE p.estado = 1
AND a.estado = 'Activo' ORDER BY p.fecha DESC";

$result = pg_query($dbConn, $query);
if (pg_num_rows($result)>0) {
	?>
<div id="containerPanelPostulantes">
	<table class="tablaResultados" style="width:100%;">
	<tr>
		<td class="columnTitle">Aviso</td>
		<td class="columnTitle">Postulante</td>
<!-- 		<td class="columnTitle">Estado</td> -->
	</tr>
	<?php 
		while($row = pg_fetch_object($result)) {
			echo "<tr>";
			echo "<td>".$row->nombre_aviso."</td>";
			echo "<td><a id='$row->perfil' href='#' class='perfilPostulante'>".$row->nombre_perfil."</a></td>";
// 			echo "<td>".$row->estado."</td>";
			echo "</tr>";
		}
}
	?>
	</table>
	
	<input type="button" class="volverPanelAdmin volver" value="Volver">

</div>
<?php include 'pie.php'; }?>